package kebapp.test;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.ByteArrayBuffer;

import android.R.string;
import android.util.Log;

public class Http_post 
{
			HttpClient httpclient = new DefaultHttpClient();
			HttpPost httppost = new HttpPost("http://kebapp.altervista.org/db.php?cmd=all");  
			String text = "culo";
	// Create a new HttpClient and Post Header
		    
	 public String get_all ()
	 
	 {
	        
			
			try {
				// Add your data
				
				/*List nameValuePairs = new ArrayList();
				nameValuePairs.add(new BasicNameValuePair("data1", "dataValue"));
				httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  */
			
				// Execute HTTP Post Request
				HttpResponse response = httpclient.execute(httppost);

				InputStream is = response.getEntity().getContent();
				BufferedInputStream bis = new BufferedInputStream(is);
				ByteArrayBuffer baf = new ByteArrayBuffer(20);

				int current = 0;

				while((current = bis.read()) != -1){
					baf.append((byte)current);
				}  
				
				
				//Log.d("Return ALL", text);
				/* Convert the Bytes read to a String. */
				text = new String(baf.toByteArray());
				
				
				
			} catch (ClientProtocolException e) {
				// TODO Auto-generated catch block
			} catch (IOException e) {
				// TODO Auto-generated catch block
			}
			//return text;
			//return text;
			return text;
			
	 
	 }
		
}
